from rest_framework import serializers
from goods.models import SPUSpecification,SpecificationOption


#商品个规格管理
class SPUSpecViewSerializer(serializers.ModelSerializer):
    #重写spu
    spu=serializers.StringRelatedField(read_only=True)
    spu_id=serializers.IntegerField()
    class Meta:
        model=SPUSpecification
        fields="__all__"

#商品规格选项管理
class SpecViewSerializer(serializers.ModelSerializer):
    #重写规格
    spec=serializers.StringRelatedField(read_only=True)
    spec_id=serializers.IntegerField()
    class Meta:
        model=SpecificationOption
        fields="__all__"

#新增规格列表
class SpecOptionsSerializer(serializers.ModelSerializer):

    class Meta:
        model=SPUSpecification
        fields=("id","name")